﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

///<summary>
///
///</summary>
public class LoadingState : State
{
    public override void ExecuteState(StateManager manager)
    {
        if (manager.IsSkipStartScnen)
        {
            ExitState(manager);
        }
    }
    public override void ExitState(StateManager manager)
    {
        SceneManager.sceneLoaded += OnSceneLoaded;
        SceneManager.LoadScene("Start");
        StateManager.GetInstance.SetState(new StartState());
		Debug.Log("转Start场景");
    }
    public override void InitState(StateManager manager)
    {
        manager.IsSkipStartScnen = false;
    }
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
        SceneManager.sceneLoaded -= OnSceneLoaded;
        AppFacde.Instance.RemoveMediator("IntroMediator");
        AppFacde.Instance.RegisterCommand(GameEvents.START_COMMAND, typeof(StartCommand));
        SendNotification(GameEvents.START_COMMAND);
    }
}
